package main.java;

import jakarta.servlet.ServletConfig;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
@WebServlet("/f2")
/**
 * @author 86187
 * @classname LifeCycleServlet
 * @time 2024/3/11
 * @project javaweb_project
 */
public class LifeCycleServlet extends HttpServlet {
    @Override
    public void init(ServletConfig config) throws ServletException {
        System.out.println("1、LifeCycleServlet被初始化了");
        super.init(config);
    }

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("2、LifeCycleServlet处于service,可以接受http请求了");
        super.service(req, resp);
    }

    @Override
    public void destroy() {
        System.out.println("3、LifeCycleServlet被销毁了");
        super.destroy();
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("doGet方法被执行了！");
        super.doGet(req, resp);
    }
}


